package com.qeeyou.apps.android.craftsman.service;

import java.util.LinkedHashMap;


public class APIConfig {

	public static String BASE_URL = "http://39.104.58.100:8080/InstallIt";

	/**
	 * 额外参数
	 */
	private final static String HEADER_TOKEN = "token";

	private static LinkedHashMap<String, String> HEADER_MAP;
	private static HeaderParInfo HEADER_PARINFO;
	
	static {
		if (BASE_URL == null) {
			try {
				BASE_URL = "http://39.104.58.100:8080/InstallIt";
			} catch (Exception e) {
			}
		}
	}
	/**
	 * 初始化必须参数
	 * @param tokenT
	 */
	public static void initHeaderPar(String tokenT){
		if (tokenT == null) {
			HEADER_PARINFO = null;
		}else{
			HEADER_PARINFO = new HeaderParInfo(tokenT);
		}
		HEADER_MAP = null;
	}
	
	/**
	 * 获取必须参数map
	 * @return
	 */
	public static LinkedHashMap<String, String> getHeaderPar(){
		if (HEADER_MAP == null) {
			if (HEADER_PARINFO != null) {
				HEADER_MAP = new LinkedHashMap<String, String>();
				HEADER_MAP.put(HEADER_TOKEN, HEADER_PARINFO.getToken());
			}
		}
		return HEADER_MAP;
	}
}

class HeaderParInfo{
	private String token;
	
	public HeaderParInfo(String tokenT){
		setToken(tokenT);
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}
}
